package LEETCODE2023.BISHUA100;

public class SolutionBM86 {
    public static void main(String[] args) {
        System.out.println(solve("9","99999999999999999999999999999999999999999999999999999999999994"));
    }

    public static String solve(String s, String t) {
        int len1 = s.length(), len2 = t.length();
        int len = Math.max(len1, len2);
        int num = 0, sum = 0, red = 0;
        StringBuilder ans = new StringBuilder();
        for (int i = 0; i <= len; i++) {
            sum += red;
            if (i < len1) {
                sum += Integer.parseInt(String.valueOf(s.charAt(len1 - 1 - i)));
            }
            if (i < len2) {
                sum += Integer.parseInt(String.valueOf(t.charAt(len2 - 1 - i)));
            }
            num = sum % 10;
            red = sum / 10;
            System.out.println(num);
            ans.append(num);
            sum = 0;
        }
        if (red > 0) {
            ans.append(red);
        }
        ans.reverse();
        return ans.charAt(0) == '0' ? ans.substring(1) : ans.toString();
//        while (index < s.length() && index < t.length()) {
//            num =
//                    index++;
//        }
// write code here
    }
}
